package com.mo.common.lucene;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;

import com.mo.common.lucene.interfaceAction.LuceneReader;
import com.mo.common.lucene.utils.LuceneClient;
import com.mo.common.lucene.utils.LuceneUtils;
import com.mo.common.lucene.utils.Page;

/**
 * public void queryParserTest() throws IOException, ParseException { Analyzer
 * analyzer = new StandardAnalyzer(); // 标准分词器，适用于英文 Analyzer analyzer = new
 * SmartChineseAnalyzer();//中文分词 Analyzer analyzer = new
 * ComplexAnalyzer();//中文分词 Analyzer analyzer = new IKAnalyzer();//中文分词 created
 * by harry on 2016/5/18.
 */
public class LuceneQueryPageManager {

	private LuceneClient luceneClient = null;

	public LuceneQueryPageManager(LuceneClient luceneClient) {
		this.luceneClient = luceneClient;
	}

	public <T> T readForTermQueryPage(LuceneReader<T> reader,
			String searchField, String userInputParserStr, Page page)
			throws Exception {
		TermQuery query = new TermQuery(new Term(searchField,
				userInputParserStr));
		return LuceneUtils.executeQueryPage(this.luceneClient.getIndexReader(),
				reader, query, page);
	}

}
